package ebcs.database.service.impl.sys;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import ebcs.database.bean.sys.FileStorage;
import ebcs.database.bean.sys.FileStorageExample;
import ebcs.database.mybatis.dao.sys.FileStorageMapper;
import ebcs.database.service.sys.IFileStorageDBService;
@Service
public class FileStorageDBServiceImpl implements IFileStorageDBService {
    
	@Autowired
	FileStorageMapper fileStDao;
	@Override
	public int insert(FileStorage fileSt) {
		return this.fileStDao.insert(fileSt);
	}

	@Override
	public FileStorage seachFileStorgeById(FileStorage fileSt) {
		
		return this.fileStDao.selectByPrimaryKey(fileSt.getStorageId());
	}

	@Override
	public int updateFileStorge(FileStorage fileSt) {
		 
		return this.fileStDao.updateByPrimaryKeySelective(fileSt);
	}

	@Override
	public List<FileStorage> searchFileStorageByEntityInfor(FileStorage fileStorage) {
		FileStorageExample fileExample = new FileStorageExample();
		FileStorageExample.Criteria cr = fileExample.createCriteria();
		cr.andEntityNameEqualTo(fileStorage.getEntityName());
		cr.andEntityNoEqualTo(fileStorage.getEntityNo());
		cr.andEntityTypeEqualTo(fileStorage.getEntityType());
		fileExample.setOrderByClause("create_date desc");
		return this.fileStDao.selectByExample(fileExample);
	}

}
